package com.jiuyou.clientController.mall.swiper;

import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.constant.DicConstants;
import com.ruoyi.shopping.domain.MallSwiper;
import com.ruoyi.shopping.service.IMallSwiperService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @author chengliang
 * @date 2022/6/17
 **/
@RestController
@RequestMapping("/client/mall/swiper")
public class MallSwiperClientController {
    @Autowired
    private IMallSwiperService service;
    @PostMapping
    public List<JSONObject> getList(){
        ArrayList<JSONObject> res = new ArrayList<>();
        MallSwiper mallSwiper = new MallSwiper();
        mallSwiper.setShowState(DicConstants.SYS_Y.getCode());
        List<MallSwiper> mallSwipers = service.selectMallSwiperList(mallSwiper);
        mallSwipers.forEach(e->{
            JSONObject jso = new JSONObject();
            jso.put("src",e.getImgSrc());
            jso.put("interval",e.getShowTime().intValue() * 1000);
            res.add(jso);
        });
        return res;
    }
}
